package teleradiologia.service;

import teleradiologia.domain.Diagnosticlab;
import teleradiologia.domain.Managerdiagnosticlab;
import teleradiologia.domain.Person;
import teleradiologia.repository.DiagnosticlabDao;
import teleradiologia.repository.ManagerdiagnosticlabDao;
import teleradiologia.repository.PersonDao;

public class ManagerdiagnosticlabManipulatorImpl implements
		ManagerdiagnosticlabManipulator {
	private ManagerdiagnosticlabDao managerdiagnosticlabDao;
	private PersonDao personDao;
	@SuppressWarnings("unused")
	private DiagnosticlabDao diagnosticlabDao;

	@Override
	public String create(Managerdiagnosticlab managerdiagnosticlab,
			Person person, Diagnosticlab diagnosticlab) {
		long id= this.personDao.create(person);
		managerdiagnosticlab.setPerson(this.personDao.getById(id));
		managerdiagnosticlab.setDiagnosticlab(diagnosticlab);
		
		return this.managerdiagnosticlabDao.create(managerdiagnosticlab);
	}

	@Override
	public void delete(Managerdiagnosticlab managerdiagnosticlab) {
		this.managerdiagnosticlabDao.delete(managerdiagnosticlab);
		this.personDao.delete(managerdiagnosticlab.getPerson());	
	}

	@Override
	public Managerdiagnosticlab getByNip(String nip) {
		return this.managerdiagnosticlabDao.getByNip(nip);
	}

	@Override
	public void setManagerdiagnosticlabDao(
			ManagerdiagnosticlabDao managerdiagnosticlabDao) {
		this.managerdiagnosticlabDao = managerdiagnosticlabDao;
	}

	@Override
	public void update(Managerdiagnosticlab managerdiagnosticlab) {
		this.personDao.update(managerdiagnosticlab.getPerson());
		this.managerdiagnosticlabDao.update(managerdiagnosticlab);
	}

	@Override
	public Managerdiagnosticlab getByIdPerson(long idPerson) {
		return this.managerdiagnosticlabDao.getByIdPerson(idPerson);
	}

	@Override
	public Managerdiagnosticlab getByKrsnumber(String krsnumber) {
		return this.managerdiagnosticlabDao.getByKrsnumber(krsnumber);
	}
	
	public void setPersonDao(PersonDao personDao) {
		this.personDao = personDao;
	}

	public void setDiagnosticlabDao(DiagnosticlabDao diagnosticlabDao) {
		this.diagnosticlabDao = diagnosticlabDao;
	}
}
